<template>
	<view>
		<!-- 导航栏 -->
		<view class="navbar">
			<view class="status_bar">
				<!-- 这里是状态栏 -->
			</view>
			<view class="navbar-header">
				<view class="left" @click="$mRouter.back()">
					<u-icon name="arrow-left" size="36"></u-icon>
				</view>
			</view>
			<view class="u-flex u-row-center u-m-t-80" style="flex-wrap: wrap;">
				<view style="width: 100%;text-align: center;font-size: 28rpx;">
					红包余额（元）
				</view>
				<view style="width: 100%;text-align: center;font-size: 58rpx;">
					{{ balance }}
				</view>
				<!-- <view class="u-flex-col">
					<text style="font-size: 28rpx;">账户余额（元）</text>
					<text style="font-size: 58rpx;">{{ balance }}</text>
				</view> -->
			<!-- 	<view class="mingxi-box" @click="$mRouter.push({ route: '/pages/purchase/zhanghu/mingxi' })">
					<text class="u-font-26" style="margin-left: 26rpx;">查看明细 </text>
					<u-icon name="arrow-right" size="26" style="margin-left: 8rpx;"></u-icon>
				</view> -->
			</view>
		</view>
		<view style="height: 308rpx"></view>
		<!--  -->
		<view class="content">
			<view class="shop-list" v-for="item in shopBlanceList" :key="item.id" @click="goDeatilsFn(item)">
				<view class="shop-info-box u-flex u-row-between">
					<view class="shop-item u-flex">
						<image :src="item.logoUrl?item.logoUrl:defaultLogo" mode="" class="shop-logo" ></image>
						<view class="shop-info">
							<view class="shop-name u-line-1">{{item.brandOwnerName}}</view>
							<view class="shop-blance">￥{{item.balance}}</view>
						</view>
					</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="u-flex shop-bot">
					<u-icon name="info-circle" color="#999"></u-icon>
					<view class="u-font-26 u-m-l-14" style="color:#999;">最高可用额为订单内本公司产品合计金额的{{item.availableRatio*100}}%</view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import { useShopStore } from '@/store/shop.js';
	import { mapState } from 'pinia';
	export default {
		data() {
			let arr = []
			for(let i = 0; i<10; i++) {
				arr.push({
					price: 10,
					where: '全场可用',
					pinpai: 'CUBITA、KHA可用',
					tiaojian: '满200可用',
					youxiaoqi: '有效期至2021-08-31'
				})
			}
			return {
				list: arr,
				balance: 0,
				shopBlanceList:[]
			}
		},
		onLoad(options) {
		
			if (options) {
				this.balance = options.balance
			}
			this.getBlanceShopList();
		},
		onShow() {
			this.getBlanceShopList();
		},
		computed:{
			...mapState(useShopStore, {storeShop: 'shop'})
		},
		methods: {
			goDeatilsFn(data){
				this.$mRouter.push({ route: '/pages/purchase/zhanghu/tradeDetails?data='+JSON.stringify(data) })
			},
			async getBlanceShopList(){
				uni.showLoading({
					title:'loading...'
				})
				let params = {
					shopId:this.storeShop.id
				}
				const res = await this.$newHttp.post('api/AccountBook/GetAccountBooks',params);
				uni.hideLoading()
				console.log(res);
				if(res.code == 200){
					this.shopBlanceList= res.data;
				}else{
					this.$u.toast('获取红包列表失败，错误信息：'+res.erroMessage)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.navbar {
		position: fixed;
		width: 100%;
		height: 308rpx;
		border-radius: 0 0 15rpx 15rpx;
		background-color: $theme-color;
		/* #ifdef H5 */
		padding: 35rpx 0;
		/* #endif */
		font-size: 36rpx;
		font-weight: 500;
		z-index: 999;
		.navbar-header {
			text-align: center;
			position: relative;
			.left {
				position: absolute;
				left: 35rpx;
			}
		}
	}
	.mingxi-box {
		display: flex;
		align-items: center;
		width: 200rpx;
		height: 70rpx;
		border: 1px solid $uni-text-color;
		border-right: none;
		border-radius: 35rpx 0 0 35rpx;
		text-align: center;
	}
	.content {
		// margin-top: 308rpx;
		// position: absolute;
		padding: 0 35rpx;
		.shop-list{
			background-color: #FFFFFF;
			box-sizing: border-box;
			margin-top: 30rpx;
			border-radius: 20rpx;
			.shop-info-box{
				padding: 50rpx 30rpx 30rpx;
			}
			.shop-bot{
				border-top: 1rpx solid #eaeaea;
				padding: 18rpx 30rpx;
			}
			.shop-item{
				.shop-logo{
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
					margin-right: 16rpx;
				}
				.shop-name{
					font-size: 30rpx;
					color: #333333;
					font-weight: 400;
				}
				.shop-blance{
					font-size: 32rpx;
					color: #333333;
					font-weight: 500;
					margin-top: 16rpx;
				}
			}
		}
	}
	.item {
		position: relative;
		background-color: #fff;
		padding: 45rpx 20rpx 20rpx 30rpx;
	}
	.text-item {
		position: relative;
		// padding: 45rpx 20rpx 20rpx 30rpx;
	}
</style>
